<template xmlns:v-action="http://www.w3.org/1999/xhtml">
  <div>
    <a-card :bordered="false">
      <!--<div class="table-page-search-wrapper">
        <a-form layout="inline">
          <a-row :gutter="48">
            <a-col :md="8" :sm="24">
              <a-form-item label="手机号码">
                <a-input v-model="queryParam.mobile" placeholder="请输入"/>
              </a-form-item>
            </a-col>

            <a-col :md="8" :sm="24">
              <span class="table-page-search-submitButtons">
                <a-button v-action:query type="primary" @click="$refs.table.refresh(true)">查询</a-button>
                <a-button v-action:query style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>-->
      <a-button @click="handleGoBack" style="padding-bottom: -10px">返回</a-button>
      <s-table
        ref="table"
        size="default"
        :columns="columns"
        :data="loadData"
        :indentSize="40"
      >

        <span slot="avatarUrl" slot-scope="text,record">
          <template>
            <div class="dfhead">
              <img :src="record.avatarUrl" alt="" style="width: 50px;height: auto;">
            </div>
        </template>
      </span>
        <span slot="gender" slot-scope="text,record">
          <template>
              {{record.gender==2?'女':'男'}}
        </template>
      </span>

        <span slot="state" slot-scope="text">
        {{ text | statusFilter }}
      </span>
      </s-table>
    </a-card>
  </div>
</template>

<script>
  import STable from '@/components/table/'
  import { getConsumePerson } from '../../../api/dashboard/chartData'

  export default {
    components: {
      STable
    },
    props: {
      record: {
        default: ''
      }
    },
    //--############  data() ###############-->
    data() {
      return {
        // 高级搜索 展开/关闭
        advanced: false,
        // 查询参数
        queryParam: {},
        // 表头
        columns: [
          {
            title: '微信头像',
            dataIndex: 'avatarUrl',
            scopedSlots: { customRender: 'avatarUrl' }
          },
          {
            title: '昵称',
            dataIndex: 'nickName'
          },
          {
            title: '性别',
            dataIndex: 'gender',
            scopedSlots: { customRender: 'gender' }
          },
          {
            title: '手机号码',
            dataIndex: 'mobile'
          },
          {
            title: 'openid',
            dataIndex: 'openid'
          }

        ],
        // 加载数据方法 必须为 Promise 对象
        loadData: parameter => {
          this.queryParam.companyId = this.record.companyid;
          if(this.record.status!=null){
            this.queryParam.state = this.record.status;
          }
          console.log(this.queryParam);
          return getConsumePerson(Object.assign(parameter, this.queryParam))
            .then(res => {
              console.log(res.result);
              return res.result
            })
        },
        selectedRowKeys: [],
        selectedRows: []
      }
    },
    //--############  data() ###############-->
    //--############  methods() ###############-->
    methods: {
      toggleAdvanced() {
        this.advanced = !this.advanced
      },
      handleOk() {
        // 新增/修改 成功时，重载列表
        this.$refs.table.refresh(true)
      },
      close() {
        this.$emit('close')
        this.visible = false
        this.form.resetFields()
        this.mdl = {}
      },
      handleCancel() {
        this.close()
      },
      handleGoBack () {
        this.$emit('onGoBack')
      },
    },
    filters: {
      statusFilter(state) {
        const statusMap = {
          1: '微信',
          2: '支付宝',
          3: '会员卡',
          4: '积分兑换'
        }
        return statusMap[state]
      }
    }
    //--############  methods() ###############-->
  }
</script>
